package com.sanjiahantang.youjiaclient.module.complain.models.impl;

import android.content.Context;

import com.sanjiahantang.youjiaclient.base.BaseBean;
import com.sanjiahantang.youjiaclient.base.CallBack;
import com.sanjiahantang.youjiaclient.config.ConfigValue;
import com.sanjiahantang.youjiaclient.http.BaseDelegate;
import com.sanjiahantang.youjiaclient.http.OkHttpClientManager;
import com.sanjiahantang.youjiaclient.module.common.beans.StringBean;
import com.sanjiahantang.youjiaclient.module.complain.beans.ComplainBean;
import com.sanjiahantang.youjiaclient.module.complain.models.IComplainModel;
import com.squareup.okhttp.Request;

import java.util.Map;

/**
 * Created by zy on 2017/10/21.
 */

public class ComplainModel implements IComplainModel {
    @Override
    public void findCustomerComplaint(final Context context, Map<String, Object> params, final CallBack<ComplainBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/customer/complaint/phone/findCustomerComplaint", params,
                new BaseDelegate.ResultCallback<ComplainBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(ComplainBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }

    @Override
    public void findCustomerBeComplaint(final Context context, Map<String, Object> params, final CallBack<ComplainBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/customer/complaint/phone/findCustomerBeComplaint", params,
                new BaseDelegate.ResultCallback<ComplainBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(ComplainBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }


    @Override
    public void findMaxId(final Context context, Map<String, String> params, final CallBack<StringBean> callBack) {
        OkHttpClientManager.postAsyn(context, ConfigValue.API_URL + "/customer/complaint/phone/findMaxId", params,
                new BaseDelegate.ResultCallback<StringBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(StringBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }

    @Override
    public void addCustomerComplaint(final Context context, Map<String, Object> params, final CallBack<ComplainBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/customer/complaint/phone/addCustomerComplaint", params,
                new BaseDelegate.ResultCallback<ComplainBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(ComplainBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }
}
